# 导入模块
import time

from selenium import webdriver
from selenium.webdriver.firefox.service import Service

# 实例化浏览器对象：类名()
gecko_driver_path = 'C:/Users/Lenovo/AppData/Local/Programs/Python/Python310/geckodriver.exe'
service = Service(executable_path=gecko_driver_path)
driver = webdriver.Firefox(service=service)

# 打开网页：必须包含协议头
driver.get('http://www.baidu.com')

# 观察效果：出现机器人控制的浏览器即为成功
time.sleep(3)

# 关闭页面
driver.quit()